﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nutrapp.DBAL;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Nutrapp.Models
{
    public class RecipeModel
    {


        [HiddenInput(DisplayValue = false)]
        public int ID { get; set; }
        
        [Required(ErrorMessage = "Please enter a name")]
        [StringLength(30, ErrorMessage = "Name cannot be longer than 30 characters.")]
        public String Name { get; set; }

        [Required]
        [Range(1, int.MaxValue, ErrorMessage = "Please enter a positive price")]
        public int? Cost { get; set; }

        public int? Rating { get; set; }

        public String Picture { get; set; }

        [Required(ErrorMessage = "Please enter ingredients")]
        public List<Recipe_Ingredient> IngredientLines { get; set; }

        [DataType(DataType.MultilineText)]
        public String Instruction { get; set; }


        public int Protein { get; set; }
        public int Carbohydrate { get; set; }
        public int Calories { get; set; }
        public int Fat { get; set; }

        public List<Ingredient> getIngredientList()
        {
            using (NutrappDataContext context = new NutrappDataContext())
            {
                List<Ingredient> list = context.Ingredients.ToList();
                return list;
            }
        }

        public List<Unit> getUnitList()
        {
            using (NutrappDataContext context = new NutrappDataContext())
            {
                List<Unit> list = context.Units.ToList();
                return list;
            }
        }

    }
}